#coding=utf8
from utils.path_generator import filePath
from utils.readExcel import ReadExcel
from configparser import ConfigParser

class GetInputData:

    @staticmethod
    def getExcelsAndSheetsDic():
        configer = ConfigParser()
        configer.read(filePath.config_path + "excel.ini", encoding="utf-8")
        sectionAndOptionDic = {}
        for section in configer.sections():
            if configer.has_option(section, "xlsName"):
                tempList = []
                for option in configer.options(section):#注意configer.options(sec)读取出来的option全是小写字母
                    if option != "xlsname" and configer.get(section,option):
                        tempList.append(configer.get(section, option))
                sectionAndOptionDic[configer.get(section,"xlsName")] = tempList

        return sectionAndOptionDic

    @staticmethod
    def getAllData():
        excelsAndSheetsDic = GetInputData.getExcelsAndSheetsDic()
        listData = []
        for excel in excelsAndSheetsDic:
            for sheet in excelsAndSheetsDic[excel]:
                re = ReadExcel(filePath.path_excel + excel, sheet)
                listData += re.dict_data()
        return listData
allDataBeforeFilter = GetInputData.getAllData()
